<template>
  <div class="layout-container">
    <el-container class="main-container">
      <!-- 顶部导航栏 -->
      <el-header class="header-wrapper">
        <Head />
      </el-header>

      <!-- 主体内容区域 -->
      <el-container class="content-wrapper">
        <!-- 侧边栏 -->
        <el-aside
          :width="isCollapse ? '64px' : '180px'"
          class="sidebar-wrapper"
        >
          <Aside />
        </el-aside>

        <!-- 主内容区 -->
        <el-main class="main-content">
          <Main />
        </el-main>
      </el-container>
    </el-container>
  </div>
</template>

<script>
import Head from "@/components/finance/Head.vue";
import Aside from "@/components/finance/Aside.vue";
import Main from "@/components/finance/Main.vue";

export default {
  components: {
    Head,
    Aside,
    Main,
  },

  data() {
    return {
      isCollapse: false,
    };
  },

  methods: {
    toggleSidebar() {
      this.isCollapse = !this.isCollapse;
    },
  },
};
</script>

<style scoped>
.layout-container {
  height: 97.7vh;
  min-width: 960px;
  overflow: hidden;
}

.main-container {
  height: 100%;
  flex-direction: column;
}

/* 头部样式 */
.header-wrapper {
  padding: 0;
  height: 60px !important;
  background: linear-gradient(90deg, #2c3e50, #3498db);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  z-index: 100;
}

/* 内容区域样式 */
.content-wrapper {
  flex: 1;
  height: calc(100vh - 60px);
}

/* 侧边栏样式 */
.sidebar-wrapper {
  background: #304156;
  transition: width 0.28s;
  position: relative;
  box-shadow: 2px 0 6px rgba(0, 21, 41, 0.35);
  z-index: 99;
}

.sidebar-toggle {
  position: absolute;
  top: 16px;
  right: -12px;
  width: 24px;
  height: 24px;
  background: #304156;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 0 6px rgba(0, 0, 0, 0.3);
  z-index: 100;
  transition: all 0.28s;
}

.sidebar-toggle:hover {
  background: #409eff;
}

.sidebar-toggle i {
  color: #fff;
  font-size: 14px;
}

/* 主内容区域样式 */
.main-content {
  flex: 1;
  padding: 20px;
  background: #f0f2f5;
  overflow: auto;
  height: 100%;
}

.main-content::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.1);
  border-radius: 4px;
}

.main-content::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.05);
  border-radius: 4px;
}

/* 响应式设计 */
@media (max-width: 768px) {
  .sidebar-wrapper {
    position: fixed;
    left: 0;
    top: 60px;
    bottom: 0;
    z-index: 1000;
  }

  .main-content {
    margin-left: 0;
  }
}
</style>
